package cn.jingzhuan.fm.ui

import android.annotation.SuppressLint
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v7.app.AppCompatActivity
import android.view.MotionEvent
import dagger.android.AndroidInjection
import dagger.android.DispatchingAndroidInjector
import dagger.android.support.HasSupportFragmentInjector
import javax.inject.Inject

/**
 * Base Activity
 *
 * Created by donglua on 2017/5/10.
 */

@SuppressLint("Registered")
open class BaseActivity : AppCompatActivity(), HasSupportFragmentInjector
{

  @Inject internal lateinit var supportFragmentInjector: DispatchingAndroidInjector<Fragment>

  var isStop = false
    get

  override fun onCreate(savedInstanceState: Bundle?) {
    AndroidInjection.inject(this)
    super.onCreate(savedInstanceState)
  }

  protected open fun injectable() = true

  override fun onResume() {
    super.onResume()
  }

  override fun onPause() {
    super.onPause()
  }

  override fun onStop() {
    super.onStop()
    isStop = true
  }

  override fun onStart() {
    super.onStart()
    isStop = false
  }

  override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
    return super.dispatchTouchEvent(ev)
  }

  override fun supportFragmentInjector() = supportFragmentInjector

}
